import redis
from flask import Flask
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from flask_session import Session
from flask.ext.wtf import CSRFProtect
from flask_sqlalchemy import SQLAlchemy
from config import Config

app = Flask(__name__)




# 将所有配置信息存放到Config类中
app.config.from_object(Config)
# 配置mysql数据库信息
db = SQLAlchemy(app)
# 配置redis 数据库信息
redis_store = redis.StrictRedis(host=Config.REDIS_HOST, port=Config.REDIS_PORT)
# CSRP保护
CSRFProtect(app)
# Session 利用Flask_Script扩展将Session保存到Redis数据库中
Session(app)
# 使用Flask_Script 扩展让程序能够一命令形式运行
manager = Manager(app)
# 数据库迁移扩展
Migrate(app, db)
manager.add_command('db', MigrateCommand)


@app.route('/')
def index():
    return 'helloworld'

if __name__ == "__main__":
    manager.run()